package com.csun.cmny.provider.controller;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.OmcOrderServiceItemContentService;
import com.csun.cmny.provider.vo.OrderServiceItemContentVo;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.google.common.base.Preconditions;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/orderServiceItemContent")
public class OmcOrderServiceItemContentController extends BaseController {

    @Resource
    CmnyMessageSource cmnyMessageSource;

    @Resource
    OmcOrderServiceItemContentService omcOrderServiceItemContentService;

    //@LogAnnotation(isSaveRequestData = true, isSaveResponseData = true)
    @PostMapping(value = "/queryListByOrderServiceItemId/{orderServiceItemId}")
    public Wrapper queryListByOrderId(@PathVariable Long orderServiceItemId) {

        // 校验Id是否为空
        Preconditions.checkArgument(orderServiceItemId != null, cmnyMessageSource
                .getMessage("orderServiceItem.id.null", null));
        List<OrderServiceItemContentVo> orderServiceItemContentVos = omcOrderServiceItemContentService.selectByOrderServiceItemId(orderServiceItemId);
        //return WrapMapper.ok(orderServiceItemContentVos);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource
                .getMessage("operation.success", null),orderServiceItemContentVos);
    }
}
